package com.olympus.hermes.product.controller;

import com.olympus.hermes.product.bean.dto.category.CategoryTreeTypeDTO;
import com.olympus.hermes.product.bean.dto.category.CreateCategoryDTO;
import com.olympus.hermes.product.bean.dto.category.UpdateCategoryDTO;
import com.olympus.hermes.product.service.CategoryService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author Mickey
 * @since 2021/1/12
 */
@RestController
@AllArgsConstructor
@RequestMapping("/product/category")
public class CategoryController {

    private final CategoryService categoryService;

    @GetMapping("/list")
    public Map<String, Object> list() {

        return null;
    }

    @PostMapping("/create")
    public void create(@RequestBody CreateCategoryDTO createCategory) {
        categoryService.create(createCategory);
    }

    @PutMapping("/update")
    public void update(@RequestBody UpdateCategoryDTO updateCategory) {
        categoryService.update(updateCategory);
    }

    @DeleteMapping("/delete/{id}")
    public void delete(@PathVariable("id") Long id) {
        categoryService.delete(id);
    }

    @GetMapping("/all")
    public List<CategoryTreeTypeDTO> all() {
        return categoryService.all();
    }
}
